package freezzz.server;

import com.friendfeed.api.Entry;
import com.friendfeed.api.EntryListResponse;
import com.friendfeed.api.internal.gson.GsonFactory;
import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;


/**
 * Created by Ivan Litsvinenka e Emanuele Ricci
 * Date: 30-ago-2009
 * Time: 6.53.37
 */
public class test {

    public static void main ( String[] args ) {
        try {
            URL url = new URL ( "http://friendfeed-api.com/v2/feed/freezzz" );
            BufferedReader reader = new BufferedReader ( new InputStreamReader ( url.openStream () ) );
            String line;
            String responce = "";
            while ( ( line = reader.readLine () ) != null ) {
                System.out.println ( line );
                responce = responce.concat ( line );
            }
            reader.close ();
            Gson gson = GsonFactory.createGson ();
            EntryListResponse r = gson.fromJson ( responce, EntryListResponse.class );
            List<Entry> events = r.getEntries ();

            for ( Entry ent : events ) {
                System.out.println ( "Via:" + ent.getVia ().getName () + "From:" + ent.getFrom ().getName () + " Body" + ent.getBody () + " Date" + ent.getDate () );
            }

        } catch ( MalformedURLException e ) {
            // ...
        } catch ( IOException e ) {
            // ...
        }
    }
}
